/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scanner;

import java.util.ArrayList;
import java.util.List;

import structures.table.symboltable.ItemInfo;

/**
 *
 * @author Vlad
 */
public class ScannerOutput {

    private List<Token> tokens;
    private ScannerError error;

    public ScannerOutput(List<Token> tokens) {
        this.tokens = tokens;
        error = new ScannerError(); // creates instance of ScannerError with 
        // errCode = ScannerError.NO_ERROR;
    }

    public ScannerOutput(ScannerError error) {
        this.error = error;
    }

    public ScannerError getError() {
        return error;
    }

    public List<Token> getTokens() {
        return tokens;
    }
    
    public List<ItemInfo> getItems() {
    	List<ItemInfo> result = new ArrayList<ItemInfo>();
    	
    	for (Token token : tokens) {
    		result.add(token.getInfo());
    	}
    	
    	return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ScannerOutput other = (ScannerOutput) obj;
        if (this.tokens != other.tokens && (this.tokens == null || !this.tokens.equals(other.tokens))) {
            return false;
        }
        if (this.error != other.error && (this.error == null || !this.error.equals(other.error))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 47 * hash + (this.tokens != null ? this.tokens.hashCode() : 0);
        hash = 47 * hash + (this.error != null ? this.error.hashCode() : 0);
        return hash;
    }
}
